#include "StdAfx.h"
// #include "capage.h" - precompiled header
#include "resource.h"
#include "Charplan.h"
#include "CharplanView.h"
#include "CAPage.h"

IMPLEMENT_DYNAMIC(CAPage, CDialog)
BEGIN_MESSAGE_MAP(CAPage, CDialog)
    ON_WM_CREATE()
    ON_WM_SIZE()
END_MESSAGE_MAP()

// Constructor. Only have to call the base class
CAPage::CAPage(UINT idd, CWnd*pParent) : CDialog(idd, pParent)
{
}

CAPage::~CAPage(void)
{
}


CCharplanDoc* CAPage::GetDocument()
{
    // One level UP
    CWnd* p = GetParent();
    ASSERT(p); // no parent
    ASSERT(strcmp(p->GetRuntimeClass()->m_lpszClassName, "CTabCtrl")  == 0);     // not the right parent

    // another level up
    p = p->GetParent();
    ASSERT(p); // no parent (tabctrl not attached to view)
    ASSERT(strcmp(p->GetRuntimeClass()->m_lpszClassName, "CCharplanView")  == 0);     // not right parent

    // get the document of the view
    return ((CCharplanView*)p)->GetDocument();
}


void CAPage::OnCancel()
{
}

void CAPage::OnOK()
{
}




int CAPage::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CDialog::OnCreate(lpCreateStruct) == -1)
        return -1;

    CRect r;
    GetWindowRect(r);
    mc_init_size.cx = r.Width();
    mc_init_size.cy = r.Height();

    return 0;
}



void CAPage::SetupToolTips()
{
    mToolTips.Create(this);
    mToolTips.SetDelayTime(TTDT_AUTOPOP,0);
    mToolTips.SetDirection(PPTOOLTIP_TOPEDGE_LEFT);
    mToolTips.SetBehaviour(PPTOOLTIP_CLOSE_LEAVEWND);
    mToolTips.SetDelayTime(TTDT_INITIAL,500);

}
BOOL CAPage::OnInitDialog()
{
    CDialog::OnInitDialog();

    SetupToolTips();

    return TRUE;
}

BOOL CAPage::PreTranslateMessage(MSG* pMsg)
{
    mToolTips.RelayEvent(pMsg);
    return CDialog::PreTranslateMessage(pMsg);
}


void CAPage::OnSize(UINT nType, int cx, int cy)
{
    CDialog::OnSize(nType, cx, cy);

    m_resizer.Move();
}
